home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / GAMES / P_ROBO31 / BTEAM2.PR < prev    next >
Text File  |  1993-02-10  |  3KB  |  102 lines

  1. (**************************************************************************)
  2. (*                             W A R N I N G                              *)
  3. (*                                                                        *)
  4. (*  This Robot has NOT been designed to take advantage of the advanced    *)
  5. (*  features of P-ROBOTS, such as, Shields, Fuel or Obstructions.         *)
  6. (**************************************************************************)
  7.  
  8.   PROCEDURE BTEAM2;
  9.  
  10. TeamAlly = "bteam1";
  11.  
  12. { A Tag-team robot.
  13.  
  14.   This robot walks the walls in a clockwise fashion, expecting its counterpart
  15.   to be walking the opposite wall at all times.  Should a team mate get taken
  16.   out, one can still cover the board in a fairly effective fashion.
  17.  
  18.   W. Baird  ...  12/89
  19. }
  20.  
  21.   CONST
  22.     side_time = 220;
  23.  
  24.   VAR
  25.     s_dir : Integer;
  26.     s_dist : Integer;
  27.     spd : Integer;
  28.     turn_time : Integer;
  29.     turn_time1 : Integer;
  30.  
  31.     PROCEDURE GOTO(x, y : Integer);
  32.     VAR heading : Integer;
  33.     BEGIN
  34.       heading := Angle_To(x, y);
  35.       WHILE (distance(loc_x, loc_y, x, y) > 150) DO DRIVE(heading, 100);
  36.       WHILE (distance(loc_x, loc_y, x, y) > 10) DO DRIVE(heading, 20);
  37.       spd := 0;
  38.       DRIVE(0, 0);
  39.     END;
  40.  
  41.     PROCEDURE robot(r_dir : Integer);
  42.     BEGIN
  43.       REPEAT
  44.         DRIVE(r_dir, spd);
  45.         s_dir := s_dir+20;
  46.         WHILE SCAN(s_dir, 10) = 0 DO
  47.           s_dir := s_dir-20;
  48.         s_dist := SCAN(s_dir, 10);
  49.         IF s_dist > 625 THEN
  50.           IF time < turn_time1 THEN
  51.             BEGIN
  52.               REPEAT
  53.                 s_dir := s_dir-20
  54.               UNTIL SCAN(s_dir, 10) > 0;
  55.               s_dist := SCAN(s_dir, 10);
  56.               IF s_dist > 39 THEN
  57.                 BEGIN
  58.                   CANNON(s_dir, s_dist);
  59.                   CANNON(s_dir, s_dist+60);
  60.                 END;
  61.             END
  62.           ELSE
  63.         ELSE
  64.           IF s_dist > 39 THEN
  65.             BEGIN
  66.               CANNON(s_dir, s_dist);
  67.               CANNON(s_dir, s_dist+60);
  68.             END;
  69.       UNTIL time >= turn_time;
  70.       DRIVE(r_dir, 40);
  71.       WHILE speed > 50 DO
  72.         BEGIN
  73.           s_dir := s_dir+20;
  74.           WHILE SCAN(s_dir, 10) = 0 DO
  75.             s_dir := s_dir-20;
  76.           s_dist := SCAN(s_dir, 10);
  77.           IF s_dist > 39 THEN
  78.             BEGIN
  79.               CANNON(s_dir, s_dist);
  80.               CANNON(s_dir, s_dist);
  81.             END;
  82.         END;
  83.       turn_time := time DIV side_time*side_time+side_time;
  84.       turn_time1 := turn_time-20;
  85.     END;                          {robot}
  86.  
  87.   BEGIN
  88.  
  89.     s_dir := 14400;
  90.     GOTO(900, 900);
  91.     turn_time := 300;
  92.     turn_time1 := 280;
  93.     robot(270);
  94.     spd := 100;
  95.     REPEAT
  96.       robot(Angle_To(900, 100));
  97.       robot(Angle_To(100, 100));
  98.       robot(Angle_To(100, 900));
  99.       robot(Angle_To(900, 900));
  100.     UNTIL DEAD;
  101.   END;
  102.